package org.s3.project.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.ibatis.annotations.Param;
import org.s3.project.common.R;
import org.s3.project.entity.User;
import org.s3.project.mapper.UserMapper;
import org.s3.project.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

/**
 * @author cfx
 * @version 1.0
 * @Description
 * @date 2025/2/9 10:30
 */
@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService {
    @Autowired
    private UserMapper userMapper;
    //用户登录
    @Override
    public User login(String username, String password) {
        return baseMapper.login(username, password);
    }

    @Override
    public User getUserById(int id) {
        return userMapper.selectUserById(id);
    }

    /**
     * 删除用户
     * @param id 用户id
     * @return 删除结果
     */
    @Override
    public int deleteUser(int id) {
        return userMapper.deleteUser(id);
    }

    /**
     * 修改用户信息
     * @param user 用户对象
     * @return 修改结果
     */

    @Override
    public int updateUser(User user) {
        return userMapper.updateUser(user);
    }


    /**
     * 修改用户状态
     * @param user 用户对象
     * @return 修改结果
     */
    @Override
    public int updateUserStatus(User user) {
        return userMapper.updateUserStatus(user);
    }

    /**
     * 批量删除用户
     * @param ids 用户id数组
     */
    @Override
    public int deleteUsers(int[] ids) {
        return userMapper.deleteUsers(ids);
    }
    /**
     * 用户模糊查询
     * @param name 用户名称
     * @param create_time 创建时间
     * @param create_timeOne 创建时间1
     * @return 查询结果
     */
    @Override
    public List<User> selectUserLike(String name, String create_time, String create_timeOne) {
        return userMapper.selectUserLike(name,create_time,create_timeOne);
    }

    /**
     * 添加用户
     * @param user 用户对象
     * @return 添加结果
     */
    @Override
    public int addUser(User user) {
        return userMapper.addUser(user);
    }

    @Override
    public int updateUserAvatar(String avatar, Integer id) {
        return userMapper.updateUserAvatar(avatar,id);
    }


}
